# Select the last time-stamp and the average over all values.
select mean() from `my_series`
-
+
# Select the first time-stamp and first value:
select first() from `my_series`
-
+
List of supported aggregation and filter functions:
limit
Syntax:
limit(max_points, aggr_function)
-
+
Returns at most `max_points` and uses a given aggregation function to reduce
the number of points if needed.
Example:
- # Returns at most 100 points for 'my-series'. The original values are
- # returned in case hundred or less points are found. In case more points
+ # Returns at most 100 points for 'my-series'. The original values are
+ # returned in case hundred or less points are found. In case more points
# are found a mean aggregation function is used.
select limit(100, mean) from "my-series"
Example:
# Get the sum of the values collected over the last 24 hours per hour.
- select sum(1h) from "series-001" between now - 1d and now
+ select sum(1h) from "series-001" between now - 1d and now
max
Example:
# Get the maximum value in 'series-001' over the last week.
- select max(now) from "series-001" between now - 1w and now
+ select max(now) from "series-001" between now - 1w and now
min
Example:
# Get the minimum value per day from 'series-001' between two dates.
- select min(1d) from "series-001" between '2016-11-14' and '2016-11-21'
+ select min(1d) from "series-001" between '2016-11-14' and '2016-11-21'
mean
Example:
- # Get average value of 'series-001' up until now.
- select mean(now) from "series-001" before now
+ # Get average value of 'series-001' up until now.
+ select mean(now) from "series-001" before now
median
# Select all positive values from 'series-001'
select filter(> 0) from 'series-001'
-
+
# Select all values containing 'error' and not 'unavailable
select filter(~'error') => filter(!~'unavailable') from 'some-log-series'
+ # Select all values starting with 'error' using a regular expression
+ select filter(/error.*/) from 'some-log-series'
+
+ # Filter out Not-a-number (nan) and Infinite values
+ select filter(!=nan) => filter(!=inf) => filter(!=-inf) from 'some-float-series'
+
first
-----
Syntax:
first([ts])
-
+
Returns the first value in each `ts` time window. (Or just the first value)
Example:
-
+
# Select the first value from 'series-001'
select first() from 'series-001'
-
+
# Select the first value per day from 'series-001'
select first(1d) from 'series-001'
-
+
# Select the first value in 2018 from 'series-001'
select first() from 'series-001' after '2018'
-
-
+
+
last
----
Syntax:
last([ts])
-
+
Returns the last value in each `ts` time window. (Or just the last value)
Example:
-
+
# Select the last value from 'series-001'
select last() from 'series-001'
-
+
# Select the last value per day from 'series-001'
select last(1d) from 'series-001'
-
+
# Select the last value in 2017 from 'series-001'
select last() from 'series-001' before '2018'
\ No newline at end of file